load("@skia_user_config//:copts.bzl", "DEFAULT_OBJC_COPTS")
load("//bazel:skia_rules.bzl", "exports_files_legacy", "select_multi", "skia_cc_deps", "skia_cc_library", "skia_objc_library")

licenses(["notice"])

exports_files_legacy()

skia_cc_library(
    name = "sk_app",
    testonly = True,
    srcs = [
        "CommandSet.cpp",
        "Window.cpp",
    ] + select({
        "@platforms//os:linux": ["//tools/sk_app/unix:srcs"],
        "//conditions:default": [],
        # TODO(kjlubick) add Windows/Mac support
    }),
    hdrs = [
        "Application.h",
        "CommandSet.h",
        "Window.h",
    ],
    visibility = ["//:__subpackages__"],
    deps = [
        "//:skia_internal",
        "//tools:legacy_tool_utils",
        "//tools/skui",
        "//tools/timer:legacy_timer",
        "//tools/window",
    ] + select({
        "@platforms//os:linux": ["//tools/sk_app/unix:deps"],
        "//conditions:default": [],
    }),
)

skia_objc_library(
    name = "sk_app_objc",
    testonly = True,
    srcs = [
        "RasterWindowContext.h",
        "Window.cpp",
        "WindowContext.cpp",
    ] + select_multi(
        {
            # TODO(kjlubick, jmbetancourt) Graphite backend
            "//src/gpu:gl_ganesh": [
                "GLWindowContext.cpp",
                "GLWindowContext.h",
            ],
            "//src/gpu:metal_ganesh": [
                "MetalWindowContext.h",
                "MetalWindowContext.mm",
            ],
        },
    ) + select({
        "@platforms//os:macos": ["//tools/sk_app/mac:srcs"],
        "//conditions:default": [],
        # TODO ios support
    }),
    hdrs = [
        "Application.h",
        "DisplayParams.h",
        "Window.h",
        "WindowContext.h",
    ],
    copts = DEFAULT_OBJC_COPTS + [
        "-Wno-deprecated-declarations",
        "-DGL_SILENCE_DEPRECATION",
    ],
    visibility = ["//:__subpackages__"],
    deps = [
        ":platform_deps",
        "//:skia_internal",
        "//tools/skui",
        "//tools/timer:legacy_timer",
    ],
)

skia_cc_deps(
    name = "platform_deps",
    testonly = True,
    visibility = ["//visibility:private"],
    deps = select({
        "@platforms//os:macos": ["//tools/sk_app/mac:deps"],
        "//conditions:default": [],
    }),
)
